package gui.funcionarios;

import java.awt.Color;
import java.awt.Component;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;
import javax.swing.border.BevelBorder;

import ge.usuarios.Professor;
import ge.util.Data;
import ge.util.Validadores;
import gui.GerenciadorDeJanelas;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Professor.java
 *
 * Created on 05/11/2010, 16:07:01
 */


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
/**
 *
 * @author Caio
 */

public class ProfessorPanel extends javax.swing.JPanel {
        private boolean flag = true;
        private String nome;
	private int matricula;
	private String cpf;
	private String endereco;
	private Data dataAdmissao;
	private String diaAdm;
	private String mesAdm;
	private String anoAdm;
	private Data dataPosse;
	private String diaPosse;
	private String mesPosse;
	private String anoPosse;
	private String telefone;
	private String email;
	private ArrayList<Integer> listaMatriculas = new ArrayList();
	private Validadores valida = new Validadores();
	private String foto;
	private String cargo;
	private List<Integer> todasMatriculas;
	private String cpf1;
	private String cpf2;
	private String cpf3;
	private JTextField caixaPosse3;
	private JTextField caixaPosse2;
	private JTextField caixaAdm3;
	private JTextField caixaAdm2;
	private JButton addFoto;
	private JTextField caixaTel1;
	private JTextField caixaTel3;
	private JTextField caixaTel2;
	private String cpf4;
	private String telefone1;
	private String telefone2;
	private String telefone3;
    /** Creates new form Professor */
    public ProfessorPanel() {
        initComponents();
       
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jLabel6 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        GroupLayout layout = new GroupLayout((JComponent)this);
        this.setLayout(layout);
        this.setSize(800, 600);
        this.setBackground(new java.awt.Color(204,204,255));
        cadastra = new javax.swing.JButton();
        cancelar = new javax.swing.JButton();
        limpar = new javax.swing.JButton();
        caixaNome = new javax.swing.JTextField();
        caixaNome.setFont(new java.awt.Font("Tahoma",0,18));
        caixaEnd = new javax.swing.JTextField();
        caixaEnd.setFont(new java.awt.Font("Tahoma",0,18));
        caixaMail = new javax.swing.JTextField();
        caixaMail.setFont(new java.awt.Font("Tahoma",0,18));
        caixaAdm = new javax.swing.JTextField();
        caixaAdm.setFont(new java.awt.Font("Tahoma",0,18));
        caixaAdm.setText("DD");
        caixaAdm.addMouseListener(new MouseAdapter() {
        	public void mouseClicked(MouseEvent evt) {
        		if(caixaAdm.isEditable()){
					caixaAdm.setText("");
				}
        		
        	}
        });
        caixaPosse = new javax.swing.JTextField();
        caixaPosse.setFont(new java.awt.Font("Tahoma",0,18));
        caixaPosse.setText("DD");
        caixaPosse.addMouseListener(new MouseAdapter() {
        	public void mouseClicked(MouseEvent evt) {
        		if(caixaPosse.isEditable()){
					caixaPosse.setText("");
				}
        		
        	}
        });
        caixaFoto = new javax.swing.JTextField();
        caixaFoto.setFont(new java.awt.Font("Tahoma",0,18));
        c1 = new javax.swing.JLabel();
        c2 = new javax.swing.JLabel();
        c3 = new javax.swing.JLabel();
        c4 = new javax.swing.JLabel();
        c5 = new javax.swing.JLabel();
        c6 = new javax.swing.JLabel();
        c7 = new javax.swing.JLabel();
        c9 = new javax.swing.JLabel();

        jLabel6.setFont(new java.awt.Font("Arial",0,24));
        jLabel6.setText("Data de admissao:");
        jLabel6.setForeground(new java.awt.Color(0,102,102));

        jLabel9.setFont(new java.awt.Font("Arial",0,24));
        jLabel9.setText("Caminho da foto:");
        jLabel9.setForeground(new java.awt.Color(0,102,102));
        {
        	caixaCpf = new JTextField();
        	caixaCpf.setText(null);
        	caixaCpf.setBackground(Color.WHITE);
        	caixaCpf.setFont(new java.awt.Font("Tahoma",0,18));
        	caixaCpf.addKeyListener(new KeyAdapter() {
        		public void keyReleased(KeyEvent evt) {
        			caixaCpfKeyReleased(evt);
        		}
        	});
        }

        jLabel5.setFont(new java.awt.Font("Arial",0,24));
        jLabel5.setText("Email:");
        jLabel5.setForeground(new java.awt.Color(0,102,102));

        jLabel4.setFont(new java.awt.Font("Arial",0,24));
        jLabel4.setText("Numero do telefone:");
        jLabel4.setForeground(new java.awt.Color(0,102,102));
        {
        	addFoto = new JButton();
        	addFoto.setText("Adiciona Foto");
        	addFoto.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
        	addFoto.setBackground(new java.awt.Color(255,255,255));
        	addFoto.addMouseListener(new MouseAdapter() {
        		public void mouseClicked(MouseEvent evt) {
        			FotoPanel adFoto = new FotoPanel();
        			caixaFoto.setText(adFoto.retornaCaminho());
        			foto = adFoto.retornaCaminho();
        			c9.setText("OK");
        			c9.setForeground(Color.GREEN);
        			
        		}
        	});
        }
        {
        	caixaCpf2 = new JTextField();
        	caixaCpf2.setText(null);
        	caixaCpf2.setBackground(Color.WHITE);
        	caixaCpf2.setFont(new java.awt.Font("Tahoma",0,18));
        	caixaCpf2.addKeyListener(new KeyAdapter() {
        		public void keyReleased(KeyEvent evt) {
        			caixaCpf2KeyReleased(evt);
        		}
        	});
        }
        {
        	caixaCpf3 = new JTextField();
        	caixaCpf3.setText(null);
        	caixaCpf3.setBackground(Color.WHITE);
        	caixaCpf3.setFont(new java.awt.Font("Tahoma",0,18));
        	caixaCpf3.addKeyListener(new KeyAdapter() {
        		public void keyReleased(KeyEvent evt) {
        			caixaCpf3KeyReleased(evt);
        		}
        	});
        }
        {
        	caixaCpf4 = new JTextField();
        	caixaCpf4.setText(null);
        	caixaCpf4.setBackground(Color.WHITE);
        	caixaCpf4.setFont(new java.awt.Font("Tahoma",0,18));
        	caixaCpf4.addKeyListener(new KeyAdapter() {
        		public void keyReleased(KeyEvent evt) {
        			caixaCpf4KeyReleased(evt);
        		}
        	});
        }

        jLabel8.setFont(new java.awt.Font("Arial",0,24));
        jLabel8.setText("Data de posse:");
        jLabel8.setForeground(new java.awt.Color(0,102,102));

        jLabel1.setFont(new java.awt.Font("Arial",0,24));
        jLabel1.setText("Nome do Professor:");
        jLabel1.setForeground(new java.awt.Color(0,102,102));

        jLabel11.setFont(new java.awt.Font("Arial",0,36)); // NOI18N
        jLabel11.setText("Cadastrar dados do Professor");
        jLabel11.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
        jLabel11.setForeground(new java.awt.Color(0,102,102));
        {
        	caixaPosse2 = new JTextField();
        	caixaPosse2.setFont(new java.awt.Font("Tahoma",0,18));
        	caixaPosse2.setText("MM");
        	caixaPosse2.addMouseListener(new MouseAdapter() {
        		public void mouseClicked(MouseEvent evt) {
        			if(caixaPosse2.isEditable()){
    					caixaPosse2.setText("");
    				}
        			
        		}
        	});
        	caixaPosse2.addKeyListener(new KeyAdapter() {
        		public void keyReleased(KeyEvent evt) {
        			try {
        				caixaPosse2KeyReleased(evt);
        			} catch (Exception e) {
        				
        				e.printStackTrace();
        			}
        		}
        	});
        }
        {
        	caixaPosse3 = new JTextField();
        	caixaPosse3.setFont(new java.awt.Font("Tahoma",0,18));
        	caixaPosse3.setText("YYYY");
        	caixaPosse3.addMouseListener(new MouseAdapter() {
        		public void mouseClicked(MouseEvent evt) {
        			if(caixaPosse3.isEditable()){
    					caixaPosse3.setText("");
    				}
        			
        		}
        	});
        	caixaPosse3.addKeyListener(new KeyAdapter() {
        		public void keyReleased(KeyEvent evt) {
        			try {
						caixaPosse3KeyReleased(evt);
					} catch (Exception e) {
						
						e.printStackTrace();
					}
        		}
        	});
        }
        {
        	caixaAdm2 = new JTextField();
        	caixaAdm2.setFont(new java.awt.Font("Tahoma",0,18));
        	caixaAdm2.setText("MM");
        	caixaAdm2.addMouseListener(new MouseAdapter() {
        		public void mouseClicked(MouseEvent evt) {
        			if(caixaAdm2.isEditable()){
    					caixaAdm2.setText("");
    				}
        			
        		}
        	});
        	caixaAdm2.addKeyListener(new KeyAdapter() {
        		public void keyReleased(KeyEvent evt) {
        			try {
        				caixaAdm2KeyReleased(evt);
        			} catch (Exception e) {
        				
        				e.printStackTrace();
        			}
        		}
        	});
        }
        {
        	caixaAdm3 = new JTextField();
        	caixaAdm3.setFont(new java.awt.Font("Tahoma",0,18));
        	caixaAdm3.setText("YYYY");
        	caixaAdm3.addMouseListener(new MouseAdapter() {
        		public void mouseClicked(MouseEvent evt) {
        			if(caixaAdm3.isEditable()){
    					caixaAdm3.setText("");
    				}
        			
        		}
        	});
        	caixaAdm3.addKeyListener(new KeyAdapter() {
        		public void keyReleased(KeyEvent evt) {
        			try {
        				caixaAdm3KeyReleased(evt);
        			} catch (Exception e) {
        				
        				e.printStackTrace();
        			}
        		}
        	});
        }
        {
        	caixaTel1 = new JTextField();
        	caixaTel1.setText(null);
        	caixaTel1.setBackground(Color.WHITE);
        	caixaTel1.setFont(new java.awt.Font("Tahoma",0,18));
        	caixaTel1.addKeyListener(new KeyAdapter() {
        		public void keyReleased(KeyEvent evt) {
        			caixaTel1KeyReleased(evt);
        		}
        	});
        }
        {
        	caixaTel2 = new JTextField();
        	caixaTel2.setText(null);
        	caixaTel2.setBackground(Color.WHITE);
        	caixaTel2.setFont(new java.awt.Font("Tahoma",0,18));
        	caixaTel2.addKeyListener(new KeyAdapter() {
        		public void keyReleased(KeyEvent evt) {
        			caixaTel2KeyReleased(evt);
        		}
        	});
        }
        {
        	caixaTel3 = new JTextField();
        	caixaTel3.setText(null);
        	caixaTel3.setFont(new java.awt.Font("Tahoma",0,18));
        	caixaTel3.setBackground(Color.WHITE);
        	caixaTel3.addKeyListener(new KeyAdapter() {
        		public void keyReleased(KeyEvent evt) {
        			caixaTel3KeyReleased(evt);
        		}
        	});
        }

        jLabel2.setFont(new java.awt.Font("Arial",0,24));
        jLabel2.setText("Numero do cpf:");
        jLabel2.setForeground(new java.awt.Color(0,102,102));

        jLabel3.setFont(new java.awt.Font("Arial",0,24));
        jLabel3.setText("Endereco:");
        jLabel3.setForeground(new java.awt.Color(0,102,102));

        cadastra.setText("Cadastrar");
        cadastra.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
        cadastra.setBackground(new java.awt.Color(255,255,255));
        cadastra.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                try {
					cadastraMouseClicked(evt);
				} catch (Exception e) {
					
					e.printStackTrace();
				}
            }
        });

        cancelar.setText("Cancelar");
        cancelar.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
        cancelar.setBackground(new java.awt.Color(255,255,255));
        cancelar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                cancelarMouseClicked(evt);
            }
        });

        limpar.setText("Limpar");
        limpar.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
        limpar.setBackground(new java.awt.Color(255,255,255));
        layout.setVerticalGroup(layout.createSequentialGroup()
        	.addContainerGap()
        	.addComponent(jLabel11, GroupLayout.PREFERRED_SIZE, 58, GroupLayout.PREFERRED_SIZE)
        	.addGap(47)
        	.addGroup(layout.createParallelGroup()
        	    .addGroup(GroupLayout.Alignment.LEADING, layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
        	        .addComponent(jLabel1, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE)
        	        .addComponent(caixaNome, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
        	    .addComponent(c1, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE))
        	.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
        	.addGroup(layout.createParallelGroup()
        	    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	        .addComponent(c2, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)
        	        .addGap(7))
        	    .addComponent(jLabel2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaCpf4, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaCpf, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaCpf2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaCpf3, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
        	.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
        	.addGroup(layout.createParallelGroup()
        	    .addGroup(GroupLayout.Alignment.LEADING, layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
        	        .addComponent(jLabel3, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
        	        .addComponent(caixaEnd, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
        	    .addComponent(c3, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE))
        	.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
        	.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
        	    .addComponent(caixaTel2, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(jLabel4, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(c4, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaTel1, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaTel3, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
        	.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
        	.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
        	    .addComponent(jLabel5, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(c5, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaMail, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
        	.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
        	.addGroup(layout.createParallelGroup()
        	    .addComponent(c6, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaAdm, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaAdm2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaAdm3, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
        	    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	        .addGap(8)
        	        .addComponent(jLabel6, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)))
        	.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
        	.addGroup(layout.createParallelGroup()
        	    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	        .addComponent(c7, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)
        	        .addGap(7))
        	    .addComponent(jLabel8, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaPosse, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaPosse2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaPosse3, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
        	.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
        	.addGroup(layout.createParallelGroup()
        	    .addComponent(c9, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaFoto, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
        	    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	        .addGap(8)
        	        .addComponent(jLabel9, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)))
        	.addGap(62)
        	.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
        	    .addComponent(cadastra, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(limpar, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(cancelar, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(addFoto, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE))
        	.addContainerGap(64, 64));
        layout.setHorizontalGroup(layout.createSequentialGroup()
        	.addGap(7)
        	.addGroup(layout.createParallelGroup()
        	    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	        .addComponent(jLabel4, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	        .addGap(0, 469, Short.MAX_VALUE))
        	    .addGroup(layout.createSequentialGroup()
        	        .addPreferredGap(jLabel4, jLabel1, LayoutStyle.ComponentPlacement.INDENT)
        	        .addGroup(layout.createParallelGroup()
        	            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                .addComponent(jLabel1, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	                .addGap(0, 463, Short.MAX_VALUE))
        	            .addGroup(layout.createSequentialGroup()
        	                .addGap(17)
        	                .addGroup(layout.createParallelGroup()
        	                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                        .addComponent(jLabel6, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	                        .addGap(0, 459, Short.MAX_VALUE))
        	                    .addGroup(layout.createSequentialGroup()
        	                        .addGap(16)
        	                        .addGroup(layout.createParallelGroup()
        	                            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                .addComponent(jLabel9, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	                                .addGap(0, 459, Short.MAX_VALUE))
        	                            .addGroup(layout.createSequentialGroup()
        	                                .addGap(17)
        	                                .addGroup(layout.createParallelGroup()
        	                                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                        .addComponent(jLabel8, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	                                        .addGap(0, 464, Short.MAX_VALUE))
        	                                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                        .addComponent(jLabel2, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	                                        .addGap(0, 460, Short.MAX_VALUE))
        	                                    .addGroup(layout.createSequentialGroup()
        	                                        .addGap(55)
        	                                        .addGroup(layout.createParallelGroup()
        	                                            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                                .addComponent(jLabel3, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	                                                .addGap(0, 461, Short.MAX_VALUE))
        	                                            .addGroup(layout.createSequentialGroup()
        	                                                .addPreferredGap(jLabel3, jLabel11, LayoutStyle.ComponentPlacement.INDENT)
        	                                                .addGroup(layout.createParallelGroup()
        	                                                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                                        .addComponent(jLabel11, GroupLayout.PREFERRED_SIZE, 501, GroupLayout.PREFERRED_SIZE)
        	                                                        .addGap(0, 58, Short.MAX_VALUE))
        	                                                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                                        .addGap(35)
        	                                                        .addComponent(jLabel5, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	                                                        .addGap(37)
        	                                                        .addGroup(layout.createParallelGroup()
        	                                                            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                                                .addComponent(caixaFoto, GroupLayout.PREFERRED_SIZE, 416, GroupLayout.PREFERRED_SIZE)
        	                                                                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 0, Short.MAX_VALUE))
        	                                                            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                                                .addComponent(caixaMail, GroupLayout.PREFERRED_SIZE, 416, GroupLayout.PREFERRED_SIZE)
        	                                                                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 0, Short.MAX_VALUE))
        	                                                            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                                                .addComponent(caixaEnd, GroupLayout.PREFERRED_SIZE, 416, GroupLayout.PREFERRED_SIZE)
        	                                                                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 0, Short.MAX_VALUE))
        	                                                            .addGroup(layout.createSequentialGroup()
        	                                                                .addGroup(layout.createParallelGroup()
        	                                                                    .addComponent(caixaCpf, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)
        	                                                                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                                                        .addComponent(caixaPosse, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE)
        	                                                                        .addGap(12))
        	                                                                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                                                        .addComponent(caixaAdm, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE)
        	                                                                        .addGap(12))
        	                                                                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                                                        .addComponent(caixaTel1, GroupLayout.PREFERRED_SIZE, 36, GroupLayout.PREFERRED_SIZE)
        	                                                                        .addGap(19)))
        	                                                                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
        	                                                                .addGroup(layout.createParallelGroup()
        	                                                                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                                                        .addComponent(addFoto, GroupLayout.PREFERRED_SIZE, 121, GroupLayout.PREFERRED_SIZE)
        	                                                                        .addGap(12))
        	                                                                    .addGroup(layout.createSequentialGroup()
        	                                                                        .addGroup(layout.createParallelGroup()
        	                                                                            .addGroup(layout.createSequentialGroup()
        	                                                                                .addGap(7)
        	                                                                                .addGroup(layout.createParallelGroup()
        	                                                                                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                                                                        .addComponent(caixaPosse2, GroupLayout.PREFERRED_SIZE, 46, GroupLayout.PREFERRED_SIZE)
        	                                                                                        .addGap(9))
        	                                                                                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                                                                        .addComponent(caixaAdm2, GroupLayout.PREFERRED_SIZE, 46, GroupLayout.PREFERRED_SIZE)
        	                                                                                        .addGap(9))
        	                                                                                    .addComponent(caixaCpf2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)))
        	                                                                            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                                                                .addComponent(caixaTel2, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)
        	                                                                                .addGap(7)))
        	                                                                        .addGroup(layout.createParallelGroup()
        	                                                                            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                                                                .addComponent(caixaTel3, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)
        	                                                                                .addGap(16))
        	                                                                            .addGroup(layout.createSequentialGroup()
        	                                                                                .addPreferredGap(caixaTel3, caixaPosse3, LayoutStyle.ComponentPlacement.INDENT)
        	                                                                                .addGroup(layout.createParallelGroup()
        	                                                                                    .addComponent(caixaPosse3, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 59, GroupLayout.PREFERRED_SIZE)
        	                                                                                    .addComponent(caixaAdm3, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 59, GroupLayout.PREFERRED_SIZE)
        	                                                                                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                                                                        .addComponent(caixaCpf3, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)
        	                                                                                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)))))))
        	                                                                .addGap(8)
        	                                                                .addGroup(layout.createParallelGroup()
        	                                                                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                                                        .addGroup(layout.createParallelGroup()
        	                                                                            .addGroup(layout.createSequentialGroup()
        	                                                                                .addGap(0, 0, Short.MAX_VALUE)
        	                                                                                .addComponent(cadastra, GroupLayout.PREFERRED_SIZE, 106, GroupLayout.PREFERRED_SIZE))
        	                                                                            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                                                                .addComponent(c7, GroupLayout.PREFERRED_SIZE, 95, GroupLayout.PREFERRED_SIZE)
        	                                                                                .addGap(0, 13, Short.MAX_VALUE))
        	                                                                            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                                                                .addComponent(c6, GroupLayout.PREFERRED_SIZE, 86, GroupLayout.PREFERRED_SIZE)
        	                                                                                .addGap(0, 22, Short.MAX_VALUE))
        	                                                                            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                                                                .addGap(0, 0, Short.MAX_VALUE)
        	                                                                                .addComponent(c4, GroupLayout.PREFERRED_SIZE, 95, GroupLayout.PREFERRED_SIZE)
        	                                                                                .addGap(11)))
        	                                                                        .addGap(17)
        	                                                                        .addComponent(limpar, GroupLayout.PREFERRED_SIZE, 99, GroupLayout.PREFERRED_SIZE))
        	                                                                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                                                        .addComponent(caixaCpf4, GroupLayout.PREFERRED_SIZE, 36, GroupLayout.PREFERRED_SIZE)
        	                                                                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
        	                                                                        .addComponent(c2, GroupLayout.PREFERRED_SIZE, 95, GroupLayout.PREFERRED_SIZE)
        	                                                                        .addGap(0, 81, Short.MAX_VALUE))))
        	                                                            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                                                .addComponent(caixaNome, GroupLayout.PREFERRED_SIZE, 416, GroupLayout.PREFERRED_SIZE)
        	                                                                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 0, Short.MAX_VALUE)))))))))))))))))
        	.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
        	.addGroup(layout.createParallelGroup()
        	    .addComponent(cancelar, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 99, GroupLayout.PREFERRED_SIZE)
        	    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	        .addComponent(c9, GroupLayout.PREFERRED_SIZE, 95, GroupLayout.PREFERRED_SIZE)
        	        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED))
        	    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	        .addComponent(c3, GroupLayout.PREFERRED_SIZE, 95, GroupLayout.PREFERRED_SIZE)
        	        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED))
        	    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	        .addComponent(c1, GroupLayout.PREFERRED_SIZE, 95, GroupLayout.PREFERRED_SIZE)
        	        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED))
        	    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	        .addPreferredGap(cancelar, c5, LayoutStyle.ComponentPlacement.INDENT)
        	        .addComponent(c5, GroupLayout.PREFERRED_SIZE, 74, GroupLayout.PREFERRED_SIZE)
        	        .addGap(13))));
        limpar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                limparMouseClicked(evt);
            }
        });

        caixaNome.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                caixaNomeKeyReleased(evt);
                
            }
        });

        caixaEnd.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                caixaEndKeyReleased(evt);
            }
        });

        caixaMail.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                caixaMailKeyReleased(evt);
            }
        });

        caixaAdm.addKeyListener(new KeyAdapter() {
        	public void keyReleased(java.awt.event.KeyEvent evt) {
        		try {
        			caixaAdmKeyReleased(evt);
        		} catch (Exception e) {
        			
        			e.printStackTrace();
        		}
        	}
        });

        caixaPosse.addKeyListener(new KeyAdapter() {
        	public void keyReleased(java.awt.event.KeyEvent evt) {
        		try {
        			caixaPosseKeyReleased(evt);
        		} catch (Exception e) {
        			
        			e.printStackTrace();
        		}
        	}
        });

        caixaFoto.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                caixaFotoKeyReleased(evt);
            }
        });

    }// </editor-fold>
    
    protected void caixaAdm3KeyReleased(KeyEvent evt) throws Exception {
    	String ano = caixaAdm3.getText();
		if (ano.length() == 4) {
			if (teclaPressionada(evt)) {
				caixaAdm2.setEditable(true);
			} else {
				caixaAdm2.setEditable(false);
			}
		}
		anoAdm = ano;
		String data = diaAdm +"/"+ mesAdm +"/"+ anoAdm;
		try {
			Data dt = new Data(data);
		} catch (Exception e) {
			c6.setForeground(Color.RED);
			c6.setText("INVALIDO");
			return;
		}
		c6.setForeground(Color.GREEN);
		c6.setText("OK");
		this.dataAdmissao = new Data(data);
		
	}

	protected void caixaAdm2KeyReleased(KeyEvent evt) throws Exception {
    	String mes = caixaAdm2.getText();
		if (mes.length() == 2) {
			if (teclaPressionada(evt)) {
				caixaAdm2.setEditable(true);
			} else {
				caixaAdm2.setEditable(false);
			}
		}
		mesAdm = mes;
		String data = diaAdm +"/"+ mesAdm +"/"+ anoAdm;
		try {
			Data dt = new Data(data);
		} catch (Exception e) {
			c6.setForeground(Color.RED);
			c6.setText("INVALIDO");
			return;
		}
		c6.setForeground(Color.GREEN);
		c6.setText("OK");
		this.dataAdmissao = new Data(data);
		
	}

	private void cadastraMouseClicked(java.awt.event.MouseEvent evt) throws Exception { 
    	for(Component component: this.getComponents()){
            if(component instanceof JLabel){
            	if(component.getForeground().equals(Color.RED)){
            		JOptionPane.showMessageDialog(null,"Algum dado invalido");
            		return;
            	}
            }
    	}
       String cargo = "Professor";
        Professor professor = new Professor(nome, cpf, endereco, telefone, email, dataAdmissao, dataPosse, foto, cargo, GerenciadorDeJanelas.todasMatriculas);
        GerenciadorDeJanelas.todosProfessores.add(professor);
        GerenciadorDeJanelas.todasMatriculas.add(professor.getMatricula());
        
     // transforma em xml
        String xmlProfessor = GerenciadorDeJanelas.ARQUIVADOR
     	.toXML(GerenciadorDeJanelas.todosProfessores);
     // grava o arrayXml no arquivo
     	GerenciadorDeJanelas.gravar(GerenciadorDeJanelas.arquivoDeProfessores,
     			xmlProfessor);
     // transforma em xml
		String xmlMatricula = GerenciadorDeJanelas.ARQUIVADOR
				.toXML(GerenciadorDeJanelas.todasMatriculas);
     // grava o arrayXml no arquivo
		GerenciadorDeJanelas.gravar(GerenciadorDeJanelas.arquivoDeMatriculas,
				xmlMatricula);
        
        limparMouseClicked(evt);
        GerenciadorDeJanelas.window.setContentPane(GerenciadorDeJanelas.primeiroMenu);
        GerenciadorDeJanelas.window.setVisible(true);
        
}                                     

    private void cancelarMouseClicked(java.awt.event.MouseEvent evt) {                                      
        limparMouseClicked(evt);
        GerenciadorDeJanelas.window.setContentPane(GerenciadorDeJanelas.menuCadastra);
        GerenciadorDeJanelas.window.setVisible(true);
}                                     

    private void limparMouseClicked(java.awt.event.MouseEvent evt) {                                    
    	for(Component component: this.getComponents()){
            if(component instanceof JTextField){
                JTextField caixa = (JTextField)component;
                caixa.setEditable(true);
                caixa.setText("");
            }
            
        }
    	c1.setText("");c2.setText("");c3.setText("");c4.setText("");c5.setText("");c6.setText("");c7.setText("");c9.setText("");
        
        
}                                   

    private void caixaNomeKeyReleased(java.awt.event.KeyEvent evt) {                                      
        String nome = caixaNome.getText();
        if(!Validadores.validaNome(nome)){
        	c1.setForeground(Color.RED);
            c1.setText("INVALIDO");
            flag = false;
        }else{
            c1.setForeground(Color.GREEN);
            c1.setText("Ok");
        }
        this.nome = nome;
}                                     
    private boolean teclaPressionada(KeyEvent ke){  
        if ( ke.getKeyCode() == KeyEvent.VK_BACK_SPACE ){
        	return true;
        }
            return false;
    }

    
private void caixaCpfKeyReleased(java.awt.event.KeyEvent evt) {                                     
	 String cpf = caixaCpf.getText();
     if(cpf.length() == 3){
     	if(teclaPressionada(evt)){
     		caixaCpf.setEditable(true);
     	}else{
     		caixaCpf.setEditable(false);
     	}
     }
     
     this.cpf1 = cpf;
     this.cpf = cpf1+"."+cpf2+"."+cpf3+"-"+cpf4;
     if(!Validadores.validaCpf(this.cpf)){
     	c2.setForeground(Color.RED);
     	c2.setText("INVALIDO");
     }else{
     	c2.setForeground(Color.GREEN);
     	c2.setText("OK");
     }
}                                    

private void caixaEndKeyReleased(java.awt.event.KeyEvent evt) {                                     
    String end = caixaEnd.getText();
    if(!Validadores.validaEndereco(end)){
        c3.setForeground(Color.RED);
        c3.setText("INVALIDO");
        flag = false;
    }else{
        c3.setForeground(Color.GREEN);
        c3.setText("Ok");
        this.endereco = end;
    }
}                                    

private void caixaTel1KeyReleased(java.awt.event.KeyEvent evt) {                                     
	String tel = caixaTel1.getText();
    if(tel.length() == 2){
    	if(teclaPressionada(evt)){
    		caixaTel1.setEditable(true);
    	}else{
    		caixaTel1.setEditable(false);
    	}
    }

	telefone1 = tel;
	telefone = "("+telefone1+")"+telefone2+"-"+telefone3;
	if(!Validadores.validaTelefone(telefone)){
		c4.setForeground(Color.RED);
		c4.setText("INVALIDO");
	}else{
		c4.setForeground(Color.GREEN);
		c4.setText("OK");
	}
}                                    

private void caixaMailKeyReleased(java.awt.event.KeyEvent evt) {                                      
    String mail = caixaMail.getText();
    if(!Validadores.validaEmail(mail)){
        c5.setForeground(Color.RED);
        c5.setText("INVALIDO");
        flag = false;
    }else{
        c5.setForeground(Color.GREEN);
        c5.setText("Ok");
        this.email = mail;
    }
}                                     

private void caixaAdmKeyReleased(java.awt.event.KeyEvent evt) throws Exception {                                     
	String dia = caixaAdm.getText();
	if (dia.length() == 2) {
		if (teclaPressionada(evt)) {
			caixaAdm.setEditable(true);
		} else {
			caixaAdm.setEditable(false);
		}
	}
	diaAdm = dia;
	String data = diaAdm +"/"+ mesAdm +"/"+ anoAdm;
	try {
		Data dt = new Data(data);
	} catch (Exception e) {
		c6.setForeground(Color.RED);
		c6.setText("INVALIDO");
		return;
	}
	c6.setForeground(Color.GREEN);
	c6.setText("OK");
	this.dataAdmissao = new Data(data);
}                                    

private void caixaPosseKeyReleased(java.awt.event.KeyEvent evt) throws Exception {                                       
	String dia = caixaPosse.getText();
	if (dia.length() == 2) {
		if (teclaPressionada(evt)) {
			caixaPosse.setEditable(true);
		} else {
			caixaPosse.setEditable(false);
		}
	}
	diaPosse = dia;
	String data = diaPosse + "/" + mesPosse + "/" + anoPosse;
	try {
		Data dataPosse = new Data(data);
	} catch (Exception e) {
		c7.setForeground(Color.RED);
		c7.setText("Invalido");
		return;
	}
	c7.setForeground(Color.GREEN);
	c7.setText("OK");
	this.dataPosse = new Data(data);
}                                      

private void caixaFotoKeyReleased(java.awt.event.KeyEvent evt) {
	
    String caminho = caixaFoto.getText();
    if(foto.length() < 2){
    	c9.setForeground(Color.RED);
    	c9.setText("INVALIDO");
    }else{
        c9.setForeground(Color.GREEN);
        c9.setText("Ok");
    }
    this.foto = caminho;
	
}                                     

	private void caixaCpf2KeyReleased(KeyEvent evt) {
		String cpf = caixaCpf2.getText();
        if(cpf.length() == 3){
        	if(teclaPressionada(evt)){
        		caixaCpf2.setEditable(true);
        	}else{
        		caixaCpf2.setEditable(false);
        	}
        }
        this.cpf2 = cpf;
        this.cpf = cpf1+"."+cpf2+"."+cpf3+"-"+cpf4;
        if(!Validadores.validaCpf(this.cpf)){
        	c2.setForeground(Color.RED);
        	c2.setText("INVALIDO");
        }else{
        	c2.setForeground(Color.GREEN);
        	c2.setText("OK");
        }
	}
	
	private void caixaCpf3KeyReleased(KeyEvent evt) {
		String cpf = caixaCpf3.getText();
        if(cpf.length() == 3){
        	if(teclaPressionada(evt)){
        		caixaCpf3.setEditable(true);
        	}else{
        		caixaCpf3.setEditable(false);
        	}
        }
        this.cpf3 = cpf;
        this.cpf = cpf1+"."+cpf2+"."+cpf3+"-"+cpf4;
        if(!Validadores.validaCpf(this.cpf)){
        	c2.setForeground(Color.RED);
        	c2.setText("INVALIDO");
        }else{
        	c2.setForeground(Color.GREEN);
        	c2.setText("OK");
        }
	}
	
	private void caixaCpf4KeyReleased(KeyEvent evt) {
		String cpf = caixaCpf4.getText();
        if(cpf.length() == 2){
        	if(teclaPressionada(evt)){
        		caixaCpf4.setEditable(true);
        	}else{
        		caixaCpf4.setEditable(false);
        	}
        }


        this.cpf4 = cpf;
        this.cpf = cpf1+"."+cpf2+"."+cpf3+"-"+cpf4;
        if(!Validadores.validaCpf(this.cpf)){
        	c2.setForeground(Color.RED);
            c2.setText("INVALIDO");
        }else{
        	c2.setForeground(Color.GREEN);
            c2.setText("OK");
        }
	}
	
	private void caixaTel2KeyReleased(KeyEvent evt) {
		String tel = caixaTel2.getText();
		if(tel.length() == 4){
        	if(teclaPressionada(evt)){
        		caixaTel2.setEditable(true);
        	}else{
        		caixaTel2.setEditable(false);
        	}
        }
		
	        this.telefone2 = tel;
	        telefone = "("+telefone1+")"+telefone2+"-"+telefone3;
	    	if(!Validadores.validaTelefone(telefone)){
	    		c4.setForeground(Color.RED);
	    		c4.setText("INVALIDO");
	    	}else{
	    		c4.setForeground(Color.GREEN);
	    		c4.setText("OK");
	    	}
	}
	
	private void caixaTel3KeyReleased(KeyEvent evt) {
		String tel = caixaTel3.getText();
		if(tel.length() == 4){
        	if(teclaPressionada(evt)){
        		caixaTel3.setEditable(true);
        	}else{
        		caixaTel3.setEditable(false);
        	}
        }
		if(tel.length() == 4){
			c4.setForeground(Color.GREEN);
	        c4.setText("OK");
	        
		}else{
			c4.setForeground(Color.RED);
	        c4.setText("INVALIDO");
	        return;
		}
	        this.telefone3 = tel;
	        telefone = "("+telefone1+")"+telefone2+"-"+telefone3;
	        if(!Validadores.validaTelefone(telefone)){
	        	caixaTel3.setBackground(Color.RED);
		        c4.setText("INVALIDO");
	        }else{
	        	c4.setForeground(Color.GREEN);
		        c4.setText("OK");
	        }
	}
	
	private void caixaPosse2KeyReleased(KeyEvent evt) throws Exception {
		String mes = caixaPosse2.getText();
		if (mes.length() == 2) {
			if (teclaPressionada(evt)) {
				caixaPosse2.setEditable(true);
			} else {
				caixaPosse2.setEditable(false);
			}
		}
		mesPosse = mes;
		String data = diaPosse + "/" + mesPosse + "/" + anoPosse;
		try {
			Data dataPosse = new Data(data);
		} catch (Exception e) {
			c7.setForeground(Color.RED);
			c7.setText("Invalido");
			return;
		}
		c7.setForeground(Color.GREEN);
		c7.setText("OK");
		this.dataPosse = new Data(data);
	}
	
	private void caixaPosse3KeyReleased(KeyEvent evt) throws Exception {
		String ano = caixaPosse3.getText();
		if (ano.length() == 4) {
			if (teclaPressionada(evt)) {
				caixaPosse3.setEditable(true);
			} else {
				caixaPosse3.setEditable(false);
			}
		}
		anoPosse = ano;
		String data = diaPosse + "/" + mesPosse + "/" + anoPosse;
		try {
			Data dataPosse = new Data(data);
		} catch (Exception e) {
			c7.setForeground(Color.RED);
			c7.setText("Invalido");
			return;
		}
		c7.setForeground(Color.GREEN);
		c7.setText("OK");
		this.dataPosse = new Data(data);
	}

    // Variables declaration - do not modify
    private javax.swing.JLabel c1;
    private javax.swing.JLabel c2;
    private javax.swing.JLabel c3;
    private javax.swing.JLabel c4;
    private javax.swing.JLabel c5;
    private javax.swing.JLabel c6;
    private javax.swing.JLabel c7;
    private javax.swing.JLabel c9;
    private javax.swing.JButton cadastra;
    private javax.swing.JTextField caixaAdm;
    private javax.swing.JTextField caixaEnd;
    private javax.swing.JTextField caixaFoto;
    private javax.swing.JTextField caixaMail;
    private javax.swing.JTextField caixaNome;
    private JTextField caixaCpf4;
    private JTextField caixaCpf3;
    private JTextField caixaCpf2;
    private JTextField caixaCpf;
    private javax.swing.JTextField caixaPosse;
    private javax.swing.JButton cancelar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JButton limpar;
    // End of variables declaration

}
